import { _decorator, Component, Label, Node, Widget } from 'cc';
import { PlayerController } from '../PlayerController';
const { ccclass, property } = _decorator;

@ccclass('ParachuteUI')
export class ParachuteUI extends Component {

    @property(Widget)
    hight: Widget;

    @property(Widget)
    speed: Widget;

    @property(Label)
    hightLabel: Label;

    @property(Label)
    speedLabel: Label;

    start() {

    }

    update(deltaTime: number) {
        this.CheckParachute();
    }

    CheckParachute() {
        let y = PlayerController.Instance.node.getWorldPosition().y;
        this.hight.bottom = y / 500 * 400;
        this.hightLabel.string = `${y.toFixed()}米`;
        let speed = Math.abs(PlayerController.Instance._playerVelocity.y);
        this.speed.bottom = speed * 10;
        this.speedLabel.string = `${speed.toFixed()}米/秒`;
    }

}


